g_return_val_if_reached (PANGO_UNDERLINE_SINGLE);
}
-static PangoTextTransform
-get_pango_text_transform_from_style (GtkTextTransform transform)
+PangoTextTransform
+gtk_css_style_get_pango_text_transform (GtkCssStyle *style)
{
- switch (transform)
+ switch (_gtk_css_text_transform_value_get (style->font_variant->text_transform))
{
case GTK_CSS_TEXT_TRANSFORM_NONE:
return PANGO_TEXT_TRANSFORM_NONE;
g_string_append (*s, text);
}
-PangoAttrList *
-gtk_css_style_get_pango_attributes (GtkCssStyle *style)
+char *
+gtk_css_style_compute_font_features (GtkCssStyle *style)
{
- PangoAttrList *attrs = NULL;
- GtkTextDecorationLine decoration_line;
- GtkTextDecorationStyle decoration_style;
- const GdkRGBA *color;
- const GdkRGBA *decoration_color;
- int letter_spacing;
GtkCssFontVariantLigature ligatures;
GtkCssFontVariantNumeric numeric;
GtkCssFontVariantEastAsian east_asian;
- GString *s;
char *settings;
- GtkTextTransform transform;
-
- /* text-decoration */
- decoration_line = _gtk_css_text_decoration_line_value_get (style->font_variant->text_decoration_line);
- decoration_style = _gtk_css_text_decoration_style_value_get (style->font_variant->text_decoration_style);
- color = gtk_css_color_value_get_rgba (style->core->color);
- decoration_color = gtk_css_color_value_get_rgba (style->font_variant->text_decoration_color
- ? style->font_variant->text_decoration_color
- : style->core->color);
-
- if (decoration_line & GTK_CSS_TEXT_DECORATION_LINE_UNDERLINE)
- {
- attrs = add_pango_attr (attrs, pango_attr_underline_new (get_pango_underline_from_style (decoration_style)));
- if (!gdk_rgba_equal (color, decoration_color))
- attrs = add_pango_attr (attrs, pango_attr_underline_color_new (decoration_color->red * 65535. + 0.5,
- decoration_color->green * 65535. + 0.5,
- decoration_color->blue * 65535. + 0.5));
- }
- if (decoration_line & GTK_CSS_TEXT_DECORATION_LINE_OVERLINE)
- {
- attrs = add_pango_attr (attrs, pango_attr_overline_new (get_pango_overline_from_style (decoration_style)));
- if (!gdk_rgba_equal (color, decoration_color))
- attrs = add_pango_attr (attrs, pango_attr_overline_color_new (decoration_color->red * 65535. + 0.5,
- decoration_color->green * 65535. + 0.5,
- decoration_color->blue * 65535. + 0.5));
- }
- if (decoration_line & GTK_CSS_TEXT_DECORATION_LINE_LINE_THROUGH)
- {
- attrs = add_pango_attr (attrs, pango_attr_strikethrough_new (TRUE));
- if (!gdk_rgba_equal (color, decoration_color))
- attrs = add_pango_attr (attrs, pango_attr_strikethrough_color_new (decoration_color->red * 65535. + 0.5,
- decoration_color->green * 65535. + 0.5,
- decoration_color->blue * 65535. + 0.5));
- }
-
- /* letter-spacing */
- letter_spacing = _gtk_css_number_value_get (style->font->letter_spacing, 100);
- if (letter_spacing != 0)
- {
- attrs = add_pango_attr (attrs, pango_attr_letter_spacing_new (letter_spacing * PANGO_SCALE));
- }
-
- /* line-height */
- {
- double height = gtk_css_line_height_value_get (style->font->line_height);
- if (height != 0.0)
- {
- if (gtk_css_number_value_get_dimension (style->font->line_height) == GTK_CSS_DIMENSION_LENGTH)
- attrs = add_pango_attr (attrs, pango_attr_line_height_new_absolute (height * PANGO_SCALE));
- else
- attrs = add_pango_attr (attrs, pango_attr_line_height_new (height));
- }
- }
-
- /* OpenType features */
-
- s = NULL;
+ GString *s = NULL;
switch (_gtk_css_font_kerning_value_get (style->font_variant->font_kerning))
{
}
if (s)
+ return g_string_free (s, FALSE);
+ else
+ return NULL;
+}
+
+PangoAttrList *
+gtk_css_style_get_pango_attributes (GtkCssStyle *style)
+{
+ PangoAttrList *attrs = NULL;
+ GtkTextDecorationLine decoration_line;
+ GtkTextDecorationStyle decoration_style;
+ const GdkRGBA *color;
+ const GdkRGBA *decoration_color;
+ int letter_spacing;
+
+ /* text-decoration */
+ decoration_line = _gtk_css_text_decoration_line_value_get (style->font_variant->text_decoration_line);
+ decoration_style = _gtk_css_text_decoration_style_value_get (style->font_variant->text_decoration_style);
+ color = gtk_css_color_value_get_rgba (style->core->color);
+ decoration_color = gtk_css_color_value_get_rgba (style->font_variant->text_decoration_color
+ ? style->font_variant->text_decoration_color
+ : style->core->color);
+
+ if (decoration_line & GTK_CSS_TEXT_DECORATION_LINE_UNDERLINE)
{
- attrs = add_pango_attr (attrs, pango_attr_font_features_new (s->str));
- g_string_free (s, TRUE);
+ attrs = add_pango_attr (attrs, pango_attr_underline_new (get_pango_underline_from_style (decoration_style)));
+ if (!gdk_rgba_equal (color, decoration_color))
+ attrs = add_pango_attr (attrs, pango_attr_underline_color_new (decoration_color->red * 65535. + 0.5,
+ decoration_color->green * 65535. + 0.5,
+ decoration_color->blue * 65535. + 0.5));
+ }
+ if (decoration_line & GTK_CSS_TEXT_DECORATION_LINE_OVERLINE)
+ {
+ attrs = add_pango_attr (attrs, pango_attr_overline_new (get_pango_overline_from_style (decoration_style)));
+ if (!gdk_rgba_equal (color, decoration_color))
+ attrs = add_pango_attr (attrs, pango_attr_overline_color_new (decoration_color->red * 65535. + 0.5,
+ decoration_color->green * 65535. + 0.5,
+ decoration_color->blue * 65535. + 0.5));
+ }
+ if (decoration_line & GTK_CSS_TEXT_DECORATION_LINE_LINE_THROUGH)
+ {
+ attrs = add_pango_attr (attrs, pango_attr_strikethrough_new (TRUE));
+ if (!gdk_rgba_equal (color, decoration_color))
+ attrs = add_pango_attr (attrs, pango_attr_strikethrough_color_new (decoration_color->red * 65535. + 0.5,
+ decoration_color->green * 65535. + 0.5,
+ decoration_color->blue * 65535. + 0.5));
}
- transform = _gtk_css_text_transform_value_get (style->font_variant->text_transform);
+ /* letter-spacing */
+ letter_spacing = _gtk_css_number_value_get (style->font->letter_spacing, 100);
+ if (letter_spacing != 0)
+ {
+ attrs = add_pango_attr (attrs, pango_attr_letter_spacing_new (letter_spacing * PANGO_SCALE));
+ }
+
+ /* line-height */
+ {
+ double height = gtk_css_line_height_value_get (style->font->line_height);
+ if (height != 0.0)
+ {
+ if (gtk_css_number_value_get_dimension (style->font->line_height) == GTK_CSS_DIMENSION_LENGTH)
+ attrs = add_pango_attr (attrs, pango_attr_line_height_new_absolute (height * PANGO_SCALE));
+ else
+ attrs = add_pango_attr (attrs, pango_attr_line_height_new (height));
+ }
+ }
+
+ /* OpenType features */
+ {
+ char *font_features = gtk_css_style_compute_font_features (style);
+
+ if (font_features)
+ {
+ attrs = add_pango_attr (attrs, pango_attr_font_features_new (font_features));
+ g_free (font_features);
+ }
+ }
+
+ /* text-transform */
+ {
+ PangoTextTransform transform = gtk_css_style_get_pango_text_transform (style);
- if (transform != GTK_CSS_TEXT_TRANSFORM_NONE)
- attrs = add_pango_attr (attrs, pango_attr_text_transform_new (get_pango_text_transform_from_style (transform)));
+ if (transform != PANGO_TEXT_TRANSFORM_NONE)
+ attrs = add_pango_attr (attrs, pango_attr_text_transform_new (transform));
+ }
return attrs;
}
values->font = gtk_css_style_get_pango_font (style);
- values->line_height = 0.0;
- values->line_height_is_absolute = FALSE;
-
- height = gtk_css_line_height_value_get (style->font->line_height);
- if (height != 0.0)
- {
- values->line_height = height;
- if (gtk_css_number_value_get_dimension (style->font->line_height) == GTK_CSS_DIMENSION_LENGTH)
- values->line_height_is_absolute = TRUE;
- }
-
- values->letter_spacing = _gtk_css_number_value_get (style->font->letter_spacing, 100) * PANGO_SCALE;
-
/* text-decoration */
+
decoration_line = _gtk_css_text_decoration_line_value_get (style->font_variant->text_decoration_line);
decoration_style = _gtk_css_text_decoration_style_value_get (style->font_variant->text_decoration_style);
color = gtk_css_color_value_get_rgba (style->core->color);
values->appearance.strikethrough_rgba = NULL;
}
- /* text-transform */
+ /* letter-spacing */
+ values->letter_spacing = _gtk_css_number_value_get (style->font->letter_spacing, 100) * PANGO_SCALE;
+
+ /* line-height */
+
+ values->line_height = gtk_css_line_height_value_get (style->font->line_height);
+ values->line_height_is_absolute = FALSE;
+ if (values->line_height != 0.0)
+ {
+ if (gtk_css_number_value_get_dimension (style->font->line_height) == GTK_CSS_DIMENSION_LENGTH)
+ values->line_height_is_absolute = TRUE;
+ }
- transform = _gtk_css_text_transform_value_get (style->font_variant->text_transform);
- values->text_transform = get_pango_text_transform_from_style (transform);
+ /* OpenType features */
+ g_free (values->font_features);
+ values->font_features = gtk_css_style_compute_font_features (style);
+
+ /* text-transform */
+ values->text_transform = gtk_css_style_get_pango_text_transform (style);
}
static void